#ifndef __COMMON_H_
#define __COMMON_H_

#include <string.h>


#ifdef __cplusplus
extern "C" {
#endif

/****************************************************************************
*
* Specification of Abstract Syntax Notation One(ASN.1)
*
****************************************************************************/
void asnWriteInt16(unsigned char* pbBuf, unsigned short wValue);
unsigned short asnReadInt16(const unsigned char* pcbBuf);

void asnWriteInt32(unsigned char* pbBuf, unsigned long dwValue);
unsigned long asnReadInt32(const unsigned char* pcbBuf);

void asnWriteInt24(unsigned char* pbBuf, unsigned long dwValue);
unsigned long asnReadInt24(const unsigned char* pcbBuf);


unsigned char asnWriteApduLengthField(unsigned char* pbBuf, unsigned long dwLengthFieldValue);
unsigned char asnReadApduLengthField(const unsigned char* pcbBuf, unsigned long dwBufSize,
									 unsigned long* pdwLengthFieldValue);

unsigned char* decode_apdu(unsigned char* pbApdu,
						   unsigned long* pdwApduTag,
						   unsigned long* pdwLengthField);


#ifdef __cplusplus
}
#endif

#endif //__COMMON_H_
